Passed
Push — develop ( 56e412...b602c4 )
by Bjarn
01:15
created

SitesController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 12
dl 0
loc 13
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A executeLink 0 10 1
1
import {writeFileSync} from 'fs'
2
import Nginx from '../services/nginx'
3
import nginxSiteConfig from '../templates/nginxSite'
4
import {ensureDirectoryExists} from '../utils/filesystem'
5
import {getConfig, jaleSitesPath} from '../utils/jale'
6
7
class SitesController {
8
9
    executeLink = async (): Promise<void> => {
10
        const config = await getConfig()
11
        const domain = process.cwd().substring(process.cwd().lastIndexOf('/') + 1)
12
        const hostname = `${domain}.${config.domain}`
13
14
        await ensureDirectoryExists(jaleSitesPath)
15
16
        await writeFileSync(`${jaleSitesPath}/${hostname}.conf`, nginxSiteConfig(hostname, process.cwd()))
17
18
        await (new Nginx()).reload
19
    }
20
21
}
22
23
export default SitesController